home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / WillowWisp.dxr / Internal_5_tableau cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  7.4 KB  |  228 lines

  1. property spriteNum, row, motion, location, fp
  2. global tableau, stock, equal, getlist, godlist, reserve, currentsel, dimpos, extras
  3.  
  4. on beginSprite me
  5.   row = determinerow()
  6.   location = sprite(spriteNum).loc
  7.   if not objectp(tableau[row]) then
  8.     tableau.addProp(row, new(script("card pile")))
  9.     sprite(spriteNum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  10.     stock.cards.deleteAt(1)
  11.     tableau[row].addCard(spriteNum)
  12.     if voidp(reserve[row]) then
  13.       reserve.addProp(row, [])
  14.     end if
  15.     repeat with i = 1 to 2
  16.       reserve[row].add(stock.cards[1].rank & "_" & stock.cards[1].suit)
  17.       stock.cards.deleteAt(1)
  18.     end repeat
  19.   end if
  20.   candd = [#one: 12, #two: 28, #thr: 44, #fou: 60, #fiv: 76, #six: 92, #sev: 108]
  21.   fp = candd[row]
  22. end
  23.  
  24. on determinerow me
  25.   if (spriteNum >= 12) and (spriteNum <= 25) then
  26.     return #one
  27.   else
  28.     if (spriteNum >= 28) and (spriteNum <= 41) then
  29.       return #two
  30.     else
  31.       if (spriteNum >= 44) and (spriteNum <= 57) then
  32.         return #thr
  33.       else
  34.         if (spriteNum >= 60) and (spriteNum <= 73) then
  35.           return #fou
  36.         else
  37.           if (spriteNum >= 76) and (spriteNum <= 89) then
  38.             return #fiv
  39.           else
  40.             if (spriteNum >= 92) and (spriteNum <= 105) then
  41.               return #six
  42.             else
  43.               if (spriteNum >= 108) and (spriteNum <= 121) then
  44.                 return #sev
  45.               end if
  46.             end if
  47.           end if
  48.         end if
  49.       end if
  50.     end if
  51.   end if
  52. end
  53.  
  54. on mouseDown me
  55.   if sprite(spriteNum).member <> member("empty", "playing cards") then
  56.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  57.     if reserve[row].count > 0 then
  58.       sprite(tableau[row].cards[1].spnum - 1).member = member("backofcard", "playing cards")
  59.     else
  60.       sprite(tableau[row].cards[1].spnum - 1).member = member("empty", "playing cards")
  61.     end if
  62.     if spriteNum = tableau[row].getlastcard().spnum then
  63.       sprite(spriteNum).locZ = spriteNum + 1000
  64.       getlist = tableau[row]
  65.       motion = timeout(string(spriteNum)).new(5, #moving, me)
  66.     else
  67.       runcheck()
  68.     end if
  69.   else
  70.     sendSprite(spriteNum - 1, #mouseDown)
  71.   end if
  72. end
  73.  
  74. on moving me
  75.   if the mouseDown then
  76.     sprite(spriteNum).loc = the mouseLoc
  77.   else
  78.     if the mouseUp then
  79.       motion.forget()
  80.       sprite(spriteNum).locZ = spriteNum
  81.       abort()
  82.     end if
  83.   end if
  84. end
  85.  
  86. on mouseUp me
  87.   if equal then
  88.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  89.     if extras.count = 0 then
  90.       sprite(currentsel).member = member(sprite(spriteNum).member.name, "playing cards")
  91.       godlist.addCard(currentsel)
  92.       tableau[row].cards.deleteOne(tableau[row].getlastcard())
  93.       sprite(spriteNum).member = member("empty", "playing cards")
  94.       sprite(spriteNum).loc = location
  95.     else
  96.       if extras.count > 0 then
  97.         extras.sort()
  98.         repeat with i = 0 to extras.count - 1
  99.           sprite(currentsel + i).member = member(sprite(the clickOn + i).member.name, "playing cards")
  100.           sprite(the clickOn + i).member = member("empty", "playing cards")
  101.           godlist.addCard(currentsel + i)
  102.           tableau[row].cards.deleteAt(tableau[row].getcardcount())
  103.           sprite(the clickOn + i).loc = sprite(the clickOn + i).location
  104.         end repeat
  105.         extras.deleteAll()
  106.       end if
  107.     end if
  108.     getlist = VOID
  109.     godlist = VOID
  110.     equal = 0
  111.     if tableau[row].getcardcount() = 0 then
  112.       if reserve[row].count() > 0 then
  113.         sprite(fp).member = member(reserve[row][1], "playing cards")
  114.         reserve[row].deleteAt(1)
  115.         tableau[row].addCard(fp)
  116.       else
  117.         sprite(fp).member = member("empty", "playing cards")
  118.       end if
  119.     end if
  120.     repeat with u in [26, 42, 58, 74, 90, 106, 122]
  121.       if tableau[sprite(u).row].getcardcount() = 0 then
  122.         temp = [12, 28, 44, 60, 76, 92, 108]
  123.         temp2 = [26, 42, 58, 74, 90, 106, 122]
  124.         ass = temp[temp2.findPos(u)]
  125.         sprite(u).loc = sprite(ass).location
  126.         next repeat
  127.       end if
  128.       sprite(u).loc = tableau[sprite(u).row].getlastcard().location
  129.     end repeat
  130.     checkwin(currentsel)
  131.     currentsel = 0
  132.   else
  133.     if not equal then
  134.       puppetSound(3, member("drop card", "100GPak Generic SFX"))
  135.       sprite(spriteNum).loc = location
  136.       getlist = VOID
  137.       if extras > 0 then
  138.         repeat with i = 1 to extras.count
  139.           sprite(extras[i]).loc = sprite(extras[i]).location
  140.         end repeat
  141.         extras.deleteAll()
  142.       end if
  143.     end if
  144.   end if
  145.   if tableau[row].getcardcount() = 0 then
  146.     sprite(fp - 1).member = member("empty", "playing cards")
  147.   end if
  148. end
  149.  
  150. on runcheck me
  151.   ass = 0
  152.   repeat with i = 1 to tableau[row].getcardcount()
  153.     if tableau[row].cards[i].spnum = spriteNum then
  154.       ss = i
  155.       dimpos = i
  156.       exit repeat
  157.     end if
  158.   end repeat
  159.   tt = ss + 1
  160.   repeat with ret = tt to tableau[row].getcardcount()
  161.     if tableau[row].cards[ret].suit <> tableau[row].cards[ret - 1].suit then
  162.       exit repeat
  163.     end if
  164.     if (tableau[row].cards[ret].rankvalue <> (tableau[row].cards[ret - 1].rankvalue - 1)) and ((tableau[row].cards[ret].rankvalue <> 1) and (tableau[row].cards[ret - 1].rankvalue <> 13)) then
  165.       exit repeat
  166.     end if
  167.     if ret <> tableau[row].getcardcount() then
  168.       next repeat
  169.     end if
  170.     ass = 1
  171.   end repeat
  172.   if ass then
  173.     getlist = tableau[sprite(tableau[row].cards[i].spnum).row]
  174.     sprite(tableau[row].cards[ss].spnum).locZ = tableau[row].cards[ss].spnum + 1000
  175.     sprite(tableau[row].cards[ss].spnum).motion = timeout(string(row) && string(spriteNum)).new(5, #moving, sprite(tableau[row].cards[ss].spnum))
  176.     extras.add(spriteNum)
  177.     repeat with ret = tt to tableau[row].getcardcount()
  178.       sprite(tableau[row].cards[ret].spnum).locZ = tableau[row].cards[ret].spnum + 1000
  179.       sprite(tableau[row].cards[ret].spnum).motion = timeout(string(row) && string(tableau[row].cards[ret].spnum)).new(1, #keepintouch, sprite(tableau[row].cards[ret].spnum))
  180.       extras.add(tableau[row].cards[ret].spnum)
  181.     end repeat
  182.   end if
  183. end
  184.  
  185. on keepintouch me
  186.   if the mouseDown then
  187.     sprite(spriteNum).loc = point(the mouseH, sprite(spriteNum - 1).locV + 25)
  188.   else
  189.     if the mouseUp then
  190.       sprite(spriteNum).locZ = spriteNum
  191.       motion.forget()
  192.       abort()
  193.     end if
  194.   end if
  195. end
  196.  
  197. on backCardEQ me
  198.   if spriteNum <> fp then
  199.     if (sprite(spriteNum - 1).member.name <> "backofcard") and (sprite(spriteNum - 1).member.name <> "empty") then
  200.       if (getValue(sprite(spriteNum).member.name) = (getValue(sprite(spriteNum - 1).member.name) - 1)) and (getSuit(sprite(spriteNum).member.name) = getSuit(sprite(spriteNum - 1).member.name)) then
  201.         repeat with shit = spriteNum - 1 to spriteNum - 1
  202.           repeat with cakes = 1 to tableau.count
  203.             if tableau[cakes].getcardcount() = 0 then
  204.               next repeat
  205.             end if
  206.             if (getValue(sprite(shit).member.name) = (getValue(sprite(tableau[cakes].getlastcard().spnum).member.name) - 1)) and not getduplicate(tableau[cakes].getlastcard().spnum) then
  207.               return 1
  208.               exit
  209.             end if
  210.           end repeat
  211.         end repeat
  212.       else
  213.         sendSprite(spriteNum - 1, #backCardEQ)
  214.       end if
  215.     end if
  216.   end if
  217.   return 0
  218. end
  219.  
  220. on getduplicateme me, argu
  221.   if (sprite(spriteNum - 1).member.name <> "empty") and (sprite(spriteNum - 1).member.name <> "backofcard") then
  222.     if getValue(sprite(spriteNum - 1).member.name) = getValue(sprite(argu).member.name) then
  223.       return 1
  224.     end if
  225.   end if
  226.   return 0
  227. end
  228.